﻿using System;

namespace DBMock.Builders
{
    /// <summary>
    /// decimal builder
    /// </summary>
    public class DecimalBuilder : Builder
    {
        private decimal min; //min value
        private decimal max; //max value

        /// <summary>
        /// DecimalBuilder constuctor
        /// </summary>
        /// <param name="seed">seed for Random</param>
        /// <param name="min">min value</param>
        /// <param name="max">max value</param>
        public DecimalBuilder(int seed, decimal min, decimal max)
            : base(seed)
        {
            if (min > max)
            {
                throw new Exception("Minimum is larger than maximum.");
            }

            this.min = min;
            this.max = max;
        }

        public override object Build()
        {
            return min + (max - min) * (decimal)random.NextDouble();
        }
    }
}
